<template>
    <div class="twoAdd">
        <el-row>
            <el-col :span="24">one添加</el-col>
        </el-row>
        <el-form ref="form" :model="form" label-width="130px" style="margin-top:30px;">
            <el-form-item label="姓名（必填）">
                <el-input v-model="form.name" style="width:360px;"></el-input>
            </el-form-item>
            <el-form-item label="电话（必填）">
                <el-input v-model="form.mobile" style="width:360px;"></el-input>
            </el-form-item>
            <el-form-item label="密码（必填）">
                <el-input v-model="form.password" style="width:360px;"></el-input>
            </el-form-item>
            <el-form-item label="确认密码（必填）">
                <el-input v-model="form.password_confirm" style="width:360px;"></el-input>
            </el-form-item>
            <el-form-item label="状态（必填）">
                <el-select v-model="form.status" placeholder="请选择状态">
                    <el-option v-for="(item, key) in stats" :value="key" :key="key" :label="item"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="onSubmit">添加保存</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>
<script>
    import axios from 'axios'
    export default {
        name: "addshangpin",
        data() {
            return {
                form: {
                    name: '',
                    mobile: '',
                    password: '',
                    password_confirm:'',
                    status:'',
                },
                stats: { "1": '正常', "-1": '禁用' },
            }
        },
        methods: {
            //提交
            onSubmit() {
                var paramesdata = {
                    name: this.form.name,
                    mobile: this.form.mobile,
                    status:this.form.status,
                    password:this.form.password,
                    password_confirm:this.form.password_confirm,
                }
                this.$store.dispatch('allData', { method: "post", url: this.$store.state.baseurl + 'admin/admin/add', selected: 'twoData', paramesdata: paramesdata,code:'addcode' });
                // if(this.$store.state.oneData){
                //    if(this.$store.state.oneData.data.code===200){
                //         alert(this.$store.state.oneData.data.message)
                //         this.form.name='';
                //         this.form.mobile='';
                //         this.form.status='';
                //         this.form.password='';
                //         this.form.password_confirm='';
                //    }else{
                //         alert('添加失败')
                //    }
                // }
            },
        }
    }
</script>
<style scoped>
</style>